<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%String path = request.getContextPath() ;%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c"%>
<%@ taglib uri="/WEB-INF/tld/ui.tld" prefix="ui"%>
<%@ taglib uri="/WEB-INF/tld/sys.tld" prefix="sys"%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>额度管理列表</title>
<jsp:include page="../../import.jsp" flush="true" />
</head>
<script type="text/javascript">
	var grid = null;
	var _mfrId;
	$(function () {
		var id = "${id}";
		var _url = '<%=path%>/quato/quatoBscInfo/initList.do?id=' + id ;
	    $("#ligergrid1").ligerGrid({
	    	url: _url,
	    	method : 'get',
	        columns: [
	            { display: '事业部', name: 'buOrgCdNm', align:'center', width: 150 },
	            { display: '项目类型', name: 'prjTypCdNm', align:'center', width: 200 },
	            { display: '剩余可用额度(万)', name: 'remainQuato', align:'center', width: 100,
					formatter: function (rowdata,rowindex, value) {
						if (row != null) {
							return parseFloat(value).toFixed(4);
						}
					}
				},
	            { display: '风控审核通过额度(万)', name: 'auditPassQuato', align:'center', width: 100,
					formatter: function (rowdata,rowindex, value) {
						if (row != null) {
							return parseFloat(value).toFixed(4);
						}
					}
				},
	            { display: '已放款额度(万)', name: 'loanQuato', align:'center', width: 100,
					formatter: function (rowdata,rowindex, value) {
						if (rowdata != null) {
							return rowdata.loanQuato.toFixed(4);
						}
					}
				},
	            { display: '操作', width: 320 ,height:'100px', align:'center',
	            	render: function (rowdata, rowindex, value){
	            		var h='<a href="javascript:modifyQuato(';
	            		h+="'"+rowdata.id+"'";
	                    h+=')">额度变更</a>';
		                //未审核
						h+=' | ';
						h+='<a href="javascript:modifyTypCd(';
						h+="'"+rowdata.id+"'";
						h+=')">修改</a>';
						h+=' | ';
						h+='<a href="javascript:showDetail(';
						h+="'"+rowdata.id+"'";
						h+=')">详情</a>';

		                <%--<sys:funcAuth resCd="fribaseinfo_view">
			                h+=' | ';
		                    h+='<a href="javascript:modifyDetail(';
		            		h+="'"+rowdata.id+"'";
		                    h+=')">维护机构详情</a>';
	                    </sys:funcAuth>--%>
	                	return h;
	            	}
	            },
	        ],
	        pageSize:10,
	    	checkbox: true,
	        root:'rows',
	        record:'total',
	        hideLoadButton : true,
	        width: '100%',
	        height:'100%',
	        heightDiff:-2,
	        rownumbers:true,
	        fixedCellHeight:false,
	        /* isChecked: f_isChecked, onCheckRow: f_onCheckRow, onCheckAllRow: f_onCheckAllRow */
	    });
	    grid = liger.get("ligergrid1");
	    grid.setHeight(100);
	    $("#searchBar").ligerForm();
	
	    $("#searchBtn").click(function(event) {
	         var form = new liger.get("searchBar");
	         var data = form.getData();
	         var insUseCd = $("#insUseCd").val();
        	 data["insUseCd"]=insUseCd;
	         for (name in data){
	            grid.setParm(name,data[name]);
	         };
	        grid.reload();
	    });
	    
	});
<%-- 	//删除数据
	function deleteRow(_id){
		if(!_id)return;
		var _ids = [];
		_ids.push(_id);
		$.ligerDialog.confirm('确定删除吗?', function (flag) {
			if(flag == false)return;
			var wait_dialog;
			$.ajax({
				type: 'post',
				dataType:'json',
				data:{ids:JSON.stringify(_ids)},
				url: '<%=path%>/rfbase/fribaseinfo/remove.do?id='+_id,
				beforeSend: function(){
			          wait_dialog=$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING ,SQ_type: "waitting" });
			     },
				success:function(msg){
					wait_dialog.close();
					 if(msg.success == 1){
						 $.ligerDialog.SQalert({content:msg.info, SQ_type: "success"});
						 grid.reload();
					 }else{
						 $.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
					 }
				}
			});
		});
	} --%>

	//修改方法
	function add(_id){
		/*if(!_id)return;
		var callback = function () {
			grid.reload();
		};
		Add_navTab('Quato_1'+_id, "新增额度", '<%=path%>/quato/quatoBscInfo/toAddPage.do?id='+_id, callback);*/
		$.ligerDialog.SQopen({
			width: 600,
			height:300,
			title : '新增额度',
			url:'<%=path%>/quato/quatoBscInfo/toAddPage.do?id='+_id,
			onClose: function () {
				grid.reload();
			}
		});
	}

  	//修改方法
  	function modifyQuato(_id){
		$.ligerDialog.SQopen({
			width: 600,
			height:300,
			title : '修改额度',
			url:'<%=path%>/quato/quatoBscInfo/toModifyQuatoPage.do?id='+_id,
			onClose: function () {
				grid.reload();
			}
		});
  	}
  	
  	//修改方法
  	function modifyTypCd(_id){
		$.ligerDialog.SQopen({
			width: 600,
			height:300,
			title : '修改额度',
			url:'<%=path%>/quato/quatoBscInfo/toModifyPrjTypCdPage.do?id='+_id,
			onClose: function () {
				grid.reload();
			}
		});
  	}

	
	//查看详情
	function showDetail(_id){
		if(!_id)return;
		Add_navTab('Quato_4'+_id, "查看额度", '<%=path%>/quato/quatoBscInfo/toDetailPage.do?id='+_id);
	}


	//格式化时间
	function renderDate(rowdata, index, value) {
		var dateStr = "";
		if (null != value) {
			var date = new Date(value);
			dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DD);
		}
		return dateStr;
	}

	function iframeResize() {
		if (parent.mainApp) {
			parent.mainApp.parentTab.onResize();
		}
	}

	//数字格式转换成千分位
	function commafy(rowdata, index, s) {
		if(null == s) return;
		return formatMoney(s);
	}

	function formatMoney(number, places, symbol, thousand, decimal) {
		number = number || 0;
		places = !isNaN(places = Math.abs(places)) ? places : 2;
		// symbol = symbol !== undefined ? symbol : "$";
		symbol = symbol !== undefined ? symbol : "";
		thousand = thousand || ",";
		decimal = decimal || ".";
		var negative = number < 0 ? "-" : "", 
			i = parseInt(number = Math.abs(+number || 0).toFixed(places), 10)+ "",
			j = (j = i.length) > 3 ? j % 3 : 0;
		return symbol
				+ negative
				+ (j ? i.substr(0, j) + thousand : "")
				+ i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + thousand)
				+ (places ? decimal
				+ Math.abs(number - i).toFixed(places).slice(2) : "");
	}
</script>

<body class="iframeBody">
	<div class="Wrapper">
		<div class="searchArea">
			<form id="searchBar">
				<div class="fieldset1 clearFix">
					<!-- <div class="clearFix"></div> -->
					<div class="btnsBox formBtns notRight">
						<span id="addBtn" class="sq-button-round" onclick="add('${id}');">添加</span>
					</div>
			</form>
		</div>
	</div>
	<div id="ligergrid1" class="sq-grid"></div>


</body>
</html>
